package com.seednia.module.util.template.service.impl;

import java.io.IOException;
import java.io.Writer;

import com.seednia.module.util.template.service.ITemplate;

import freemarker.template.Template;
import freemarker.template.TemplateException;

/**
 * FreeMarker wrapper implementation of the template
 * 
 * @author Young Suk Ahn
 *
 */
public class FreeMarkerTemplate implements ITemplate {

	private Template theTemplate;
	
	public FreeMarkerTemplate(){}
	
	public FreeMarkerTemplate(Template theTemplate)
	{
		this.theTemplate = theTemplate;
	}
	
	@Override
	public void process(Object model, Writer out) throws IOException {
		try {
			theTemplate.process(model, out);
		} catch (TemplateException e) {
			throw new IllegalArgumentException(e);
		}
	}

}
